import React from 'react';
import { useLocation, Navigate } from 'react-router-dom';


export const withLogin = Comp => () => {
  const token = localStorage.getItem('token');
  const { pathname } = useLocation();
  if(!token && pathname !== '/login') {
    return <Navigate to="/login"></Navigate>
  }
  return <Comp></Comp>
}